<?php
namespace Home\Controller;
use Think\Controller;
class SetupController extends Controller {
    public function index(){
		$this->display('Index/homepage');
    }
	public function aa(){
		echo "this function just test git,add";
    	echo "this function just test ";
		echo "this function";
	}
	public function bug(){
		echo 'ssss#';
	}
    public function hg(){
        $aa;
    }
	public function mkplan(){
		$data['User_id']        = $_SESSION['User_phone']; //用户ID
		$data['Plan_time']      = time();//计划时间
		$data['Plan_peoplenum'] = I("num_limit");//人数
		$data['Msg_info']       = I('msg_info');//内容
		$data['Status']         = I('status');//状态
		$data['Start_time']     = I('start_time');//开始时间
		$data['End_time']       = I('end_time');//结束时间
		$data['Start']          = I('start');//开始地点
		$data['End']            = I('end');//结束地点
		$data['Host_num']       = I('host_num');//甲方人数
		$data['Trip_mode']      = I('trip_mode');//出行方式
		$data['Sex_req']        = I('sex_limit');//性别限制
		$upload = new \Think\Upload();// 实例化上传类
		$upload->maxSize   =     3145728 ;// 设置附件上传大小
		$upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
		$upload->rootPath  =     './Public/'; // 设置附件上传根目录
		$upload->savePath  =     './Uploads/plan/'.$_SESSION['User_phone'].'/'; // 设置附件上传（子）目录
		// 上传文件 
		$info   =   $upload->upload();
		for($i=0;$i<count($info);$i++){
			$pic_array[$i] = $info[$i]['savename'];
		}
		$pic_string=implode(',',$pic_array);
		$data['Host_photo'] = $pic_string;
		/*if(!$info) {// 上传错误提示错误信息
			$this->error($upload->getError());
		}*/
		$infoPlan = M('planinfo');
		$infoPlan = $infoPlan -> add($data);
		if($infoPlan){
			$this->success('成功制定计划' , U("Planinfo/index" , array('User_id' => $data['User_id'],'Plan_time' => $data['Plan_time'],'Plan_peoplenum' => $data['Plan_peoplenum'],'Msg_info' => $data['Msg_info'],'Status' => $data['Status'],'Start_time' => $data['Start_time'],'End_time' => $data['End_time'],'Start' => $data['Start'],'End' =>$data['End'],'Host_num' => $data['Host_num'],'Trip_mode' => $data['Trip_mode'],'Sex_req' => $data['Sex_req'])));
		}
	}
	public function ajaxplan(){
		
	}
	public function selfsetup(){
		$this->display('setup');
	}
	public function selfinfo(){
		$data['User_nickname']  = I("nickname");
		$data['Head_portrait']  = I("portrait");
		$birth['year']         = I('year');
		$birth['month']         = I('month');
		$birth['day']         = I('day');
		$data['birthday']       = $birth['year'].'/'.$birth['month'].'/'.$birth['day'];
		$data['Signature']      = I('signature');
		$data['User_qq']        = I('qq');
		$data['User_email']     = I('email');
		$infoPlan = M('user_basicinfo');
		$infoPlan = $infoPlan ->where('User_phone ='.$_SESSION['User_phone'])->save($data);
		if($infoPlan){
			$this->success('资料提交成功',U("Index/login",array('logintype'=> 2)));
		}
	}
}
?>